package com.financing.platform.dao.impl;

import java.sql.SQLException;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.financing.platform.dao.IProjectAnnualRevenueDao;
import com.financing.platform.dto.ProjectAnnualRevenueDTO;
import com.financing.platform.util.SqlName;

@Repository("projectAnnualRevenueDaoImpl")
public class ProjectAnnualRevenueDaoImpl extends BaseDaoImpl implements
		IProjectAnnualRevenueDao {

	public Integer insertProjectAnnualRevenue(
			ProjectAnnualRevenueDTO projectAnnualRevenueDto) {
		try {
			return (Integer) this.sqlMapClient.insert(SqlName.insertProjectAnnualRevenue, projectAnnualRevenueDto);
		} catch (SQLException e) {
			log.error("Insert into annual revenue error !",e);
			return -1;
		}
	}

	@SuppressWarnings("unchecked")
	public List<ProjectAnnualRevenueDTO> queryProjectAnnualRevenueList(
			Integer pid) {
		
		try {
			return (List<ProjectAnnualRevenueDTO>)this.sqlMapClient.queryForList(SqlName.searchProjectAnnualRevenueByPid, pid);
		} catch (SQLException e) {
			log.error("query project annual revenue list error !",e);
			return Collections.EMPTY_LIST;
		}
	}

	public int deleteProjectAnnualRevenue(Integer pid) throws SQLException {
		return this.sqlMapClient.delete(SqlName.deleteProjectAnnualRevenueByid,pid);
	}
	
	public int updateProjectAnnualRevenueByendAmount(Map<String, Object> map) throws SQLException {
		return this.sqlMapClient.update(SqlName.updateProjectAnnualRevenueByendAmount,map);
	}


}
